package ycl.important.common.base.service.impl;

import org.springframework.context.annotation.Lazy;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import ycl.important.common.base.entity.BaseMsgEntity;
import ycl.important.common.base.mapper.BaseMsgMapper;
import ycl.important.common.base.service.BaseMsgService;
import ycl.important.common.utils.AnnotationUtil;

import javax.annotation.Resource;

/**
 * 消息处理层
 *
 * @author: YCL
 * @date: 2021-08-23 20:46:25
 */
@Service
@Lazy
public abstract class
BaseMsgServiceImpl<M extends BaseMsgMapper<T>, T extends BaseMsgEntity>
		extends BaseServiceImpl<M, T>
		implements BaseMsgService<T> {

	@Resource
	private BaseMsgMapper<T> mapper;

	@Override
	@Transactional(rollbackFor = Exception.class)
	public <E extends BaseMsgEntity> void readBatch(Long userId, Class<E> t) {
		String tableName = AnnotationUtil.getTableName(t);
		mapper.msgReadBatch(userId, tableName);
	}
}
